import fw from '../framework.js'

// 创建一个永久排期
function createForeverChannel(programId, success, error) {
    var channelData = {
        "id": null,
        "name": "",
        "remark": "",
        "level": 2,
        "channelType": "DEFAULT",
        "source":2, // pc是1  小程序是2
        "channelSchedulePeriodInfos": [{
            "id": null,
            "fe_guid": fw.fe_guid(),
            "programGroupPlayMethod": 1,
            "playStartTime": "永久 00:00",
            "playStartCrontab": "永久 开始",
            "playEndTime": "永久 23:59",
            "playEndCrontab": "永久 结束",
            "type": 3,
            "periodType": 1,
            "startTime": "1900-01-01 00:00:00",
            "endTime": "2051-01-09 23:59:59",
            "channelPlayProgramGroupInfos": [{
                "programId": programId,
                "seq": 1
            }],
            "playDuration": 0,
            "playInterval": 0
        }]
    };
    fw.ajax('channel/v2/create', channelData).then(res => {
        if (res.code == 0) {
            if(success)success(res.data);
        } else {
            if(error)error(res)
        }
    })
}

module.exports = {
    create:createForeverChannel
}
